<template>
  <div>
    <script id="editor" type="text/plain"></script>
  </div>
</template>
<script>
  export default {
    name: 'UE',
    data () {
      return {
        editor: null
      }
    },
    props: {
      value: {
        type: String,
        default: function() {
        return ""
        }
      },
      config: {
        type: Object
      }
    },
    created() {
      const _this = this;
      this.$nextTick(() => {
         this.destroyed()
         this.editor = UE.getEditor('editor', this.config); // 初始化UE
         this.editor.addListener("ready", function () {
          _this.editor.setContent(_this.value); // 确保UE加载完成后，放入内容。
         });
     })
    },
    methods: {
      getUEContent() { // 获取内容方法
        return this.editor.getContent()
      },
     destroyed() {
      UE.delEditor('editor')
     }
    }
  }
</script>